package com.corelib.eventbus;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import com.corelib.BaseActivity;
import com.corelib.R;
import com.corelib.eventbus.event.MessageEvent;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import butterknife.BindView;

public class EventOne extends BaseActivity {
    @BindView(R.id.toNext)
    Button tonext;
    @Override
    protected int inflateLayoutId() {
        return R.layout.activity_event_one;
    }

    @Override
    protected void initViews(Bundle savedInstanceState) {
        EventBus.getDefault().register(this);
        tonext.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(EventOne.this,EventTwo.class));
            }
        });
    }

    @Subscribe(threadMode=ThreadMode.MAIN)
    public void MyEvent(MessageEvent event){
        Log.e("event",event.getMsg());
    }
    @Override
    protected void onDestroy() {
        EventBus.getDefault().unregister(this);
        super.onDestroy();
    }
}
